import time
from Case.python_ui.Test_data.login_data import Logindata
from Case.python_ui.Common.basepage import Basepage
from Case.python_ui.PageLocate.product_management_locator import ProductManagementLocator
from Case.python_ui.Pageobject.admin_product_managent_pages import ProductManagementPages
from Case.python_ui.Common.commontool import CommonTool
from Case.python_ui.Test_data.common_data import Commondata
from Case.python_ui.Test_data.prod_data import Product
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import StaleElementReferenceException
from Case.python_ui.mylogging.mylogging import MyLogging
from Case.python_ui.Common.business_common_tool import BusinessCommonTools
from Case.python_ui.PageLocate.user_eip_locator import UserEIPLocator
from Case.python_ui.PageLocate.user_my_resource_locator import UserMyResourceLocator
from Case.python_ui.Pageobject.user_slb_pages import UserSLBPages
from Case.python_ui.PageLocate.user_slb_locator import UserSLBLocator
from selenium.common.exceptions import NoSuchElementException, ElementClickInterceptedException, \
    ElementNotInteractableException

class UserEIPPages(Basepage):

    #进入my resource界面
    def enter_my_resource_page(self):
        doc='进入user端的myresource页面'
        for i in range(3):
            try:
                self.wait_elevisble(ProductManagementLocator.my_resource_tab, doc)
                self.click_element(ProductManagementLocator.my_resource_tab, doc)
                break
            except:
                self.refresh_page()
                continue
        time.sleep(5)
        self.wait_elevisble(ProductManagementLocator.page_total,doc)



    def get_prod_name_to_click(self,prod_name):
        doc='获取产品名称然后点击'
        prod_list=self.get_elements(ProductManagementLocator.prod_list,doc)
        time.sleep(2)
        for prod in prod_list:
            if prod.text == prod_name:
                prod.click()
        time.sleep(2)

    # 校验某个属性值是否符合预期
    def check_attribute(self, real_result, except_result):
        if real_result == except_result:
            assert True
        else:
            assert False, '实际值:' + real_result + '期望值:' + except_result

    # 判断是否包含元素
    def check_contain_str(self, string, except_string):
        if except_string in string:
            assert True
        else:
            assert False, '实际值:' + string + '期望值:' + except_string

    # 获得最新创建的instance id
    def get_instance_id(self,cmdopt,get_database_source):
        instance_id = BusinessCommonTools().get_instance_id(cmdopt, get_database_source)
        return instance_id

        # 清空筛选状态

    def clear_filter_status(self, locate,status_filter_reset_button, status_filter_ok_button):
        doc = '清空筛选状态'
        try:
            # 点击筛选按钮
            time.sleep(2)
            self.click_element(locate, doc)
            time.sleep(2)
            # 点击reset按钮
            self.click_element(status_filter_reset_button, doc)
        except ElementNotInteractableException as e:
            self.click_element(status_filter_ok_button, doc)
            return
        except ElementClickInterceptedException as e:
            self.click_element(status_filter_ok_button, doc)
            return
        else:
            time.sleep(2)
            self.click_element(status_filter_ok_button, doc)
            return

            # 清空筛选状态



        # order界面筛选项清空
    def orders_clear_status(self):
        self.clear_filter_status(UserSLBLocator.product_filter_button, UserSLBLocator.status_filter_reset_button,UserSLBLocator.status_filter_ok_button)
        time.sleep(2)
        self.clear_filter_status(UserSLBLocator.order_type_filter_button,UserSLBLocator.status_filter_reset_button2,UserSLBLocator.status_filter_ok_button2)
        time.sleep(2)
        self.clear_filter_status(UserSLBLocator.order_status_filter_button,UserSLBLocator.status_filter_reset_button3,UserSLBLocator.status_filter_ok_button3)
        time.sleep(2)
        self.clear_filter_status(UserSLBLocator.billing_method_filter_button,UserSLBLocator.status_filter_reset_button4,UserSLBLocator.status_filter_ok_button4)


     # orders界面列表倒叙展示
    def order_time_desc(self):
        doc = "将列表倒序展示"
        self.click_element(UserEIPLocator.orders_create_time_filter, doc)
        time.sleep(2)
        self.click_element(UserEIPLocator.orders_create_time_filter, doc)




    #购买包年包月EIP+释放包年包月EIP
    def create_eip_subscription(self):
        doc = '购买包年包月EIP'
        success = 'Release Successfully'
        self.enter_my_resource_page()
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        self.wait_elevisble(UserEIPLocator.eip_organization,doc)
        time.sleep(2)
        #self.click_element(ProductManagementLocator.term_of_service, doc)
        self.button_is_enabled(ProductManagementLocator.buy_now_button)
        try:
            self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
            self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        except:
            pass
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        self.button_is_enabled(ProductManagementLocator.pay_button)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        # instance_id = BusinessCommonTools().get_instance_id(cmdopt,get_database_source)
        # time.sleep(2)
        # self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        # self.click_element(UserMyResourceLocator.reset_button, doc)
        # time.sleep(5)
        # self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        # self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        # time.sleep(2)
        # self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        # self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        # time.sleep(5)
        # self.wait_elevisble(UserEIPLocator.actions_button, doc)
        # self.click_element(UserEIPLocator.actions_button, doc)
        # time.sleep(2)
        # self.click_element(UserEIPLocator.release_button, doc)
        # time.sleep(2)
        # self.switch_to_new_window()
        # time.sleep(5)
        # self.wait_elevisble(UserEIPLocator.real_release_button, doc)
        # self.click_element(UserEIPLocator.real_release_button, doc)
        # time.sleep(2)
        # self.wait_elevisble(UserEIPLocator.confirm_release_button, doc)
        # self.click_element(UserEIPLocator.confirm_release_button, doc)
        # time.sleep(5)
        # self.check_attribute(self.get_element(UserEIPLocator.release_success, doc).text, success)

        # 购买按量付费EIP-带宽计费 + 释放

    def create_eip_pag_badwidth(self):
        doc = '购买按量付费EIP-带宽计费'
        self.enter_my_resource_page()
        success = 'Release Successfully'
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        self.wait_elevisble(UserEIPLocator.eip_organization, doc)
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.pag_button, doc)
        self.click_element(UserEIPLocator.pag_button, doc)
        time.sleep(2)
        #self.click_element(ProductManagementLocator.term_of_service, doc)
        self.button_is_enabled(ProductManagementLocator.buy_now_button)
        try:
            self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
            self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        except:
            pass
        self.click_element(ProductManagementLocator.term_of_service, doc)
        self.button_is_enabled(ProductManagementLocator.pay_button)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        # instance_id = BusinessCommonTools().get_instance_id(cmdopt, get_database_source)
        # time.sleep(2)
        # self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        # self.click_element(UserMyResourceLocator.reset_button, doc)
        # time.sleep(5)
        # self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        # self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        # time.sleep(2)
        # self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        # self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        # time.sleep(5)
        # self.wait_elevisble(UserEIPLocator.actions_button, doc)
        # self.click_element(UserEIPLocator.actions_button, doc)
        # time.sleep(2)
        # self.click_element(UserEIPLocator.release_button, doc)
        # time.sleep(2)
        # self.switch_to_new_window()
        # time.sleep(5)
        # self.wait_elevisble(UserEIPLocator.real_release_button, doc)
        # self.click_element(UserEIPLocator.real_release_button, doc)
        # time.sleep(2)
        # self.wait_elevisble(UserEIPLocator.confirm_release_button, doc)
        # self.click_element(UserEIPLocator.confirm_release_button, doc)
        # time.sleep(5)
        # self.check_attribute(self.get_element(UserEIPLocator.release_success, doc).text, success)

    #进入控制台，用name查询得到instance_id
    def get_eip_instance_id(self):
        doc = '入控制台，用name查询得到instance_id'
        self.driver.refresh()
        self.wait_elevisble(ProductManagementLocator.menu_list, doc)
        self.click_element(ProductManagementLocator.menu_list, doc)
        self.get_console_product_to_click('Elastic IP Addresses')
        time.sleep(4)
        self.wait_elevisble(ProductManagementLocator.iframe, doc)
        self.driver.switch_to.frame(self.get_element(ProductManagementLocator.iframe, doc))
        self.wait_elevisble(UserEIPLocator.eip_id,doc)
        time.sleep(2)
        intance_id = self.get_element(UserEIPLocator.eip_id,doc).text
        print(intance_id)
        return intance_id




    # 新增查询产品名称然后点击
    def get_console_product_to_click(self,prouduct_name):
        doc = '查询产品名称然后点击'
        self.wait_elevisble(ProductManagementLocator.product_name_input,doc)
        self.send_keys(ProductManagementLocator.product_name_input,prouduct_name,doc)
        self.wait_elevisble(ProductManagementLocator.search_prod_ele,doc)
        time.sleep(2)
        self.click_element(ProductManagementLocator.search_prod_ele,doc)
        time.sleep(2)



    #根据instance_name查询对应的id
    def query_instance(self,intance_name):
        doc='查询intance_name'
        self.wait_elevisble(UserSLBLocator.console_instance_name_input,doc)
        self.keyboard_event(UserSLBLocator.console_instance_name_input,doc)
        self.send_keys(UserSLBLocator.console_instance_name_input,intance_name,doc)
        time.sleep(2)
        self.keyboard_event_enter(UserSLBLocator.console_instance_name_input,doc)
        self.wait_elevisble(UserSLBLocator.slb_instance_id_ele,doc)

    def release_eip(self, cmdopt, instance_id):
        doc = '释放eip'
        self.driver.get(Commondata.home_page[cmdopt]['user'])
        self.enter_my_resource_page()
        self.query_intance_id(instance_id)
        time.sleep(2)
        self.wait_elevisble(ProductManagementLocator.action_button, doc)
        time.sleep(2)
        self.click_element(ProductManagementLocator.action_button, doc)
        time.sleep(2)
        self.get_action_to_click('Release')
        self.switch_to_new_window()
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(2)
        self.wait_elevisble(ProductManagementLocator.release_button, doc)
        time.sleep(2)
        self.click_element(ProductManagementLocator.release_button, doc)
        self.wait_elevisble(ProductManagementLocator.buy_now_button, doc)
        time.sleep(2)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)


    def get_action_to_click(self,action_name):
        doc='获取操作名称然后点击'
        self.wait_elevisble(ProductManagementLocator.my_resource_action_list,doc)
        action_list_eles =self.get_elements(ProductManagementLocator.my_resource_action_list,doc)
        for action in action_list_eles:
            if action.text== action_name:
                action.click()


    # 根据instance_id查询
    def query_intance_id(self,instance_id):
        doc='查询intance_id'
        self.wait_elevisble(ProductManagementLocator.instance_id_input,doc)
        self.keyboard_event(ProductManagementLocator.instance_id_input,instance_id)
        time.sleep(2)
        self.send_keys(ProductManagementLocator.instance_id_input,instance_id,doc)
        time.sleep(2)
        self.click_element(ProductManagementLocator.instance_id_search,doc)
        self.wait_elevisble(ProductManagementLocator.order_view_detail_button,doc)



   #购买按量付费EIP-流量计费 + 释放
    def create_eip_pag_traffic(self, cmdopt,get_database_source):
        doc = '购买按量付费EIP-流量计费'
        success = 'Release Successfully'
        self.enter_my_resource_page()
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.pag_button, doc)
        self.click_element(UserEIPLocator.pag_button, doc)
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.pay_by_traffic, doc)
        self.click_element(UserEIPLocator.pay_by_traffic, doc)
        time.sleep(2)
        self.button_is_enabled(ProductManagementLocator.buy_now_button)
        try:
            self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
            self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        except:
            pass
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(2)
        self.button_is_enabled(ProductManagementLocator.pay_button)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        # instance_id = BusinessCommonTools().get_instance_id(cmdopt,get_database_source)
        # time.sleep(2)
        # self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        # self.click_element(UserMyResourceLocator.reset_button, doc)
        # time.sleep(5)
        # self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        # self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        # time.sleep(2)
        # self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        # self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        # time.sleep(5)
        # self.wait_elevisble(UserEIPLocator.actions_button, doc)
        # self.click_element(UserEIPLocator.actions_button, doc)
        # time.sleep(2)
        # self.click_element(UserEIPLocator.release_button, doc)
        # time.sleep(2)
        # self.switch_to_new_window()
        # time.sleep(2)
        # self.wait_elevisble(UserEIPLocator.real_release_button, doc)
        # self.click_element(UserEIPLocator.real_release_button, doc)
        # time.sleep(2)
        # self.wait_elevisble(UserEIPLocator.confirm_release_button, doc)
        # self.click_element(UserEIPLocator.confirm_release_button, doc)
        # time.sleep(5)
        # self.check_attribute(self.get_element(UserEIPLocator.release_success, doc).text, success)



    #按量付费eip变配
    def pag_modify(self, cmdopt,get_database_source):
        doc = '按量付费eip变配'
        self.enter_my_resource_page()
        success = 'Release Successfully'
        type = 'Modify'
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(4)
        self.wait_elevisble(UserEIPLocator.pag_button, doc)
        self.click_element(UserEIPLocator.pag_button, doc)
        time.sleep(2)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(10)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        instance_id = BusinessCommonTools().get_instance_id(cmdopt,get_database_source)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.actions_button, doc)
        self.click_element(UserEIPLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserEIPLocator.modify_button, doc)
        self.switch_to_new_window()
        time.sleep(4)
        self.wait_elevisble(UserEIPLocator.new_bandwidth, doc)
        self.click_element(UserEIPLocator.new_bandwidth, doc)
        time.sleep(2)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(10)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        time.sleep(2)
        instance_id = BusinessCommonTools().get_instance_id(cmdopt,get_database_source)
        self.click_element(UserEIPLocator.check_order_button, doc)
        time.sleep(2)
        self.orders_clear_status()
        time.sleep(2)
        self.click_element(UserSLBLocator.type_select, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.instance_id_select, doc)
        time.sleep(2)
        self.send_keys(UserSLBLocator.instance_input, instance_id, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.search_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserSLBLocator.orders_type, doc).text, type)
        self.enter_my_resource_page()
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.actions_button, doc)
        self.click_element(UserEIPLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserEIPLocator.release_button, doc)
        time.sleep(2)
        self.wait_elevisble(UserSLBLocator.actions_button, doc)
        self.click_element(UserSLBLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.release_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.wait_elevisble(UserSLBLocator.real_release_button, doc)
        self.click_element(UserSLBLocator.real_release_button, doc)
        time.sleep(2)
        self.wait_elevisble(UserSLBLocator.confirm_release_button, doc)
        self.click_element(UserSLBLocator.confirm_release_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserSLBLocator.release_success, doc).text, success)

    #包年包月eip变配
    def subscription_modify(self, cmdopt,get_database_source):
        doc = '包年包月eip变配'
        self.enter_my_resource_page()
        success = 'Release Successfully'
        type = 'Modify'
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(4)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        instance_id = BusinessCommonTools().get_instance_id(cmdopt,get_database_source)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.actions_button, doc)
        self.click_element(UserEIPLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserEIPLocator.modify_button, doc)
        self.switch_to_new_window()
        time.sleep(4)
        self.wait_elevisble(UserEIPLocator.new_bandwidth, doc)
        self.click_element(UserEIPLocator.new_bandwidth, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        time.sleep(2)
        instance_id = BusinessCommonTools().get_instance_id(cmdopt,get_database_source)
        self.click_element(UserEIPLocator.check_order_button, doc)
        time.sleep(2)
        self.orders_clear_status()
        time.sleep(2)
        self.click_element(UserSLBLocator.type_select, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.instance_id_select, doc)
        time.sleep(2)
        self.send_keys(UserSLBLocator.instance_input, instance_id, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.search_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserSLBLocator.orders_type, doc).text, type)
        self.enter_my_resource_page()
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.actions_button, doc)
        self.click_element(UserEIPLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserEIPLocator.release_button, doc)
        time.sleep(5)
        self.switch_to_new_window()
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.real_release_button, doc)
        self.click_element(UserEIPLocator.real_release_button, doc)
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.confirm_release_button, doc)
        self.click_element(UserEIPLocator.confirm_release_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserEIPLocator.release_success, doc).text, success)


    #包年包月eip续费
    def renew_subscription_eip(self,cmdopt, get_database_source):
        doc = '包年包月eip续费'
        success = 'Release Successfully'
        self.enter_my_resource_page()
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(4)
        #self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(10)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        instance_id = BusinessCommonTools().get_instance_id(cmdopt, get_database_source)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.click_element(UserEIPLocator.renew_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(4)
        new_expired_time = self.get_element(UserEIPLocator.new_expiration_date, doc)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(10)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        time.sleep(2)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(4)
        self.check_attribute(self.get_element(UserEIPLocator.new_expired_time, doc).text, new_expired_time)
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.actions_button, doc)
        self.click_element(UserEIPLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserEIPLocator.release_button, doc)
        time.sleep(5)
        self.switch_to_new_window()
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.real_release_button, doc)
        self.click_element(UserEIPLocator.real_release_button, doc)
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.confirm_release_button, doc)
        self.click_element(UserEIPLocator.confirm_release_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserEIPLocator.release_success, doc).text, success)


    #按量付费eip续费
    def renew_pag_eip(self,cmdopt, get_database_source):
        doc = '按量付费eip续费'
        success = 'Release Successfully'
        self.enter_my_resource_page()
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(4)
        self.wait_elevisble(UserEIPLocator.pag_button, doc)
        self.click_element(UserEIPLocator.pag_button, doc)
        time.sleep(2)
        #self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(10)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        instance_id = BusinessCommonTools().get_instance_id(cmdopt, get_database_source)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.click_element(UserEIPLocator.renew_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(4)
        new_expired_time = self.get_element(UserEIPLocator.new_expiration_date, doc)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(10)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        time.sleep(2)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(4)
        self.check_attribute(self.get_element(UserEIPLocator.new_expired_time, doc).text, new_expired_time)
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.actions_button, doc)
        self.click_element(UserEIPLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserEIPLocator.release_button, doc)
        time.sleep(5)
        self.switch_to_new_window()
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.real_release_button, doc)
        self.click_element(UserEIPLocator.real_release_button, doc)
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.confirm_release_button, doc)
        self.click_element(UserEIPLocator.confirm_release_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserEIPLocator.release_success, doc).text, success)




    def change_oraganization(self,cmdopt, get_database_source):
        doc = 'eip资源切换组织'
        success = 'Release Successfully'
        self.enter_my_resource_page()
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        #self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        instance_id = BusinessCommonTools().get_instance_id(cmdopt, get_database_source)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserSLBLocator.actions_button, doc)
        self.click_element(UserSLBLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.modify_organization_button, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.change_organization_select, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.change_organization_second_select, doc)
        organization = self.get_element(UserSLBLocator.change_organization_second_select, doc).text
        time.sleep(2)
        self.click_element(UserSLBLocator.submit_button, doc)
        time.sleep(2)
        js_object = 'document.getElementsByClassName("antd4-table-content")[0].scrollTo(1000,10000)'
        self.excute_js(js_object);
        time.sleep(2)
        self.check_attribute(self.get_element(UserSLBLocator.organization, doc).text, organization)
        self.wait_elevisble(UserSLBLocator.actions_button, doc)
        self.click_element(UserSLBLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.release_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.wait_elevisble(UserSLBLocator.real_release_button, doc)
        self.click_element(UserSLBLocator.real_release_button, doc)
        time.sleep(2)
        self.wait_elevisble(UserSLBLocator.confirm_release_button, doc)
        self.click_element(UserSLBLocator.confirm_release_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserSLBLocator.release_success, doc).text, success)




    def sub_to_psgy(self,cmdopt, get_database_source):
        doc = '包年包月eip转按量付费'
        success = 'Release Successfully'
        self.enter_my_resource_page()
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        instance_id = BusinessCommonTools().get_instance_id(cmdopt, get_database_source)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.change_billing_method_button, doc)
        self.click_element(UserEIPLocator.change_billing_method_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        #self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.check_order_button, doc)
        time.sleep(5)
        self.orders_clear_status()
        time.sleep(2)
        self.click_element(UserSLBLocator.type_select, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.instance_id_select, doc)
        time.sleep(2)
        self.send_keys(UserSLBLocator.instance_input, instance_id, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.search_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserSLBLocator.orders_type, doc).text, 'Change Billing Method')
        self.check_attribute(self.get_element(UserSLBLocator.orders_billing_method, doc).text, 'Subscription')
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserSLBLocator.actions_button, doc)
        self.click_element(UserSLBLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.release_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.wait_elevisble(UserSLBLocator.real_release_button, doc)
        self.click_element(UserSLBLocator.real_release_button, doc)
        time.sleep(2)
        self.wait_elevisble(UserSLBLocator.confirm_release_button, doc)
        self.click_element(UserSLBLocator.confirm_release_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserSLBLocator.release_success, doc).text, success)

    def psgy_to_sub(self,cmdopt, get_database_source):
        doc = '按量付费eip转包年包月'
        success = 'Release Successfully'
        self.enter_my_resource_page()
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.pag_button, doc)
        self.click_element(UserEIPLocator.pag_button, doc)
        time.sleep(2)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        instance_id = BusinessCommonTools().get_instance_id(cmdopt, get_database_source)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.change_billing_method_button, doc)
        self.click_element(UserEIPLocator.change_billing_method_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.check_order_button, doc)
        time.sleep(5)
        self.orders_clear_status()
        time.sleep(2)
        self.click_element(UserSLBLocator.type_select, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.instance_id_select, doc)
        time.sleep(2)
        self.send_keys(UserSLBLocator.instance_input, instance_id, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.search_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserSLBLocator.orders_type, doc).text, 'Change Billing Method')
        self.check_attribute(self.get_element(UserSLBLocator.orders_billing_method, doc).text, 'Pay-As-You-Go')
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserSLBLocator.actions_button, doc)
        self.click_element(UserSLBLocator.actions_button, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.release_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.wait_elevisble(UserSLBLocator.real_release_button, doc)
        self.click_element(UserSLBLocator.real_release_button, doc)
        time.sleep(2)
        self.wait_elevisble(UserSLBLocator.confirm_release_button, doc)
        self.click_element(UserSLBLocator.confirm_release_button, doc)
        time.sleep(5)
        self.check_attribute(self.get_element(UserSLBLocator.release_success, doc).text, success)



    def enter_eip_console(self,cmdopt, get_database_source):
        doc = '点击eip实例id进入产品控制台'
        success = 'Release Successfully'
        self.enter_my_resource_page()
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.pag_button, doc)
        self.click_element(UserEIPLocator.pag_button, doc)
        time.sleep(2)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        instance_id = BusinessCommonTools().get_instance_id(cmdopt, get_database_source)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.click_element(UserEIPLocator.eip_id, doc)



        # 新增判断按钮是否可以点击方法
    def button_is_enabled(self, locate):
        doc = '判断按钮是否可以点击'
        button = self.get_element(locate, doc)
        for i in range(5):
            time.sleep(2)
            if button.is_enabled():
                button.click()
                break


      #计费更改后，下载订单详情
    def sub_to_psgy_load(self,cmdopt, get_database_source):
        doc = '包年包月eip转按量付费'
        success = 'Release Successfully'
        self.enter_my_resource_page()
        self.wait_elevisble(ProductManagementLocator.cerate_new_tab, doc)
        self.move_mouse_to_element(ProductManagementLocator.cerate_new_tab)
        time.sleep(2)
        self.get_prod_name_to_click('Elastic IP Addresses')
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])
        instance_id = BusinessCommonTools().get_instance_id(cmdopt, get_database_source)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.reset_button, doc)
        self.click_element(UserMyResourceLocator.reset_button, doc)
        time.sleep(5)
        self.wait_elevisble(UserMyResourceLocator.instance_id_input, doc)
        self.send_keys(UserMyResourceLocator.instance_id_input, instance_id, doc)
        time.sleep(2)
        self.wait_elevisble(UserMyResourceLocator.orgnazation_search, doc)
        self.click_element(UserMyResourceLocator.orgnazation_search, doc)
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.change_billing_method_button, doc)
        self.click_element(UserEIPLocator.change_billing_method_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        #self.click_element(ProductManagementLocator.term_of_service, doc)
        time.sleep(5)
        self.click_element(ProductManagementLocator.buy_now_button, doc)
        self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
        self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        time.sleep(4)
        self.click_element(ProductManagementLocator.term_of_service, doc)
        self.click_element(ProductManagementLocator.pay_button, doc)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        time.sleep(2)
        self.click_element(UserSLBLocator.check_order_button, doc)
        time.sleep(5)
        self.orders_clear_status()
        time.sleep(2)
        self.order_time_desc()
        time.sleep(2)
        self.click_element(UserEIPLocator.view_orders_detail, doc)
        time.sleep(2)
        self.click_element(UserEIPLocator.orders_detail_download, doc)
        time.sleep(5)

    def check_bandwwidth(self, cmdopt, instance_id):
        doc = '更改计费类型界面字段校验'
        self.driver.get(Commondata.home_page[cmdopt]['user'])
        self.enter_my_resource_page()
        self.query_intance_id(instance_id)
        time.sleep(2)
        self.wait_elevisble(UserEIPLocator.change_billing_method_button, doc)
        self.click_element(UserEIPLocator.change_billing_method_button, doc)
        time.sleep(2)
        self.switch_to_new_window()
        time.sleep(5)
        self.wait_elevisble(UserEIPLocator.maximum_bandwidth, doc)
        self.check_attribute(UserEIPLocator.maximum_bandwidth, 'Maximum Bandwidth')
        time.sleep(2)
        self.button_is_enabled(ProductManagementLocator.buy_now_button)
        try:
            self.wait_elevisble(ProductManagementLocator.loading_wait, doc)
            self.wait_eleinvisble(ProductManagementLocator.loading_wait, doc)
        except:
            pass
        time.sleep(4)
        self.button_is_enabled(ProductManagementLocator.pay_button)
        self.wait_elevisble(ProductManagementLocator.pay_successful, doc)
        self.driver.close()
        all_handles = self.driver.window_handles
        self.driver.switch_to.window(all_handles[0])







